package com.zph.dao;

import java.io.IOException;
import java.io.Reader;
import java.util.List;
import java.util.Map;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;


public class test {
	private static IDatabaseDao  DAO      = null; 
	

	

	public static void main(String[] args) {
		  String resource = "MyBatis-Configuration.xml";
          Reader reader = null;
		try {
			reader = Resources.getResourceAsReader(resource);
		} catch (IOException e) {
			e.printStackTrace();
		}
          SqlSessionFactoryBuilder builder = new SqlSessionFactoryBuilder();
          SqlSessionFactory factory = builder.build(reader);
         
          
		
		while(true)
		{
			SqlSession session = factory.openSession();
			IDatabaseDao dao = session.getMapper(IDatabaseDao.class);
			List<Map> files = dao.queryCVFile();
			System.out.println("size" + files.size());
			System.out.println("id" + files.get(0).get("id"));
			try 
			{
				Thread.sleep(1000);
			} catch (InterruptedException e) 
			{
				e.printStackTrace();
			}
			session.commit();
			session.close();
			session  = null;
			
		}
	}
}
